cmake_minimum_required(VERSION 3.10)

set(CMAKE_C_COMPILER "/usr/bin/gcc")
set(CMAKE_CXX_COMPILER "/usr/bin/g++")

project(h_mempool VERSION 1.0.0)

set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
set(CMAKE_CXX_STANDARD 11)

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

# option(BUILD_SHARED_LIBS "build shared libraries" ON)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")

set(SRC_DIR "${PROJECT_SOURCE_DIR}/src")
file(GLOB_RECURSE SOURCE_DIR "${SRC_DIR}/*.c" "${SRC_DIR}/*.h")

add_definitions(-DPROJECT_VERSION=\"${PROJECT_VERSION}\")

set(CMAKE_BUILD_TYPE Debug)
# add_definitions(-DDEBUG)

set(CMAKE_CXX_FLAG "-static ${CMAKE_CXX_FLAG}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")

if(BUILD_SHARED_LIBS)
    add_definitions(-DSHARED)
    add_library(h_mempool SHARED ${SOURCE_DIR})
else()
    add_executable(h_mempool ${SOURCE_DIR})
endif()
